Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add jsdoc bundle package #10

Merged
merged 10 commits into from
Jun 8, 2022
Merged

Add jsdoc bundle package #10

merged 10 commits into from
Jun 8, 2022

Conversation

tomalec
Copy link
Member

@tomalec tomalec commented Jun 2, 2022

Changes proposed in this Pull Request:

Addresses some of the concerns from #6 (review)

Bundles multiple commonly used jsdoc plugins, so the extensions repo would need only this one dependency.
Exports a binary, that wraps commonly used jsdoc CLI arguments, for easier use.

Screenshots:

Detailed test instructions:

See example usage at woocommerce/google-listings-and-ads@develop...tweak/bundled-jsdoc
And the installation & usage instructions at https://github.com/woocommerce/grow/blob/add/jsdoc-bundle/packages/js/jsdoc/README.md

  1. npm i --save-dev https://gitpkg.now.sh/woocommerce/grow/packages/js/jsdoc?add/jsdoc-bundle
  2. Create a TRACKING.md file
    # Usage Tracking
    Some nice general description.
    <woocommerce-grow-tracking-jsdoc></woocommerce-grow-tracking-jsdoc>
  3. Create a .jsdocrc.json
    {
       "plugins": [
          "woocommerce-grow-jsdoc/tilde-alias",
          "woocommerce-grow-tracking-jsdoc/fires-description",
          "jsdoc-plugin-typescript",
          "jsdoc-advanced-types-plugin",
          "jsdoc-plugin-intersection"
       ],
       "typescript": {
          "moduleRoot": "js/src"
       }
    }
  4. npx woocommerce-grow-jsdoc

Additional details:

Changelog entry

Add - -jsdoc bundle package

(cherry picked from commit cb88933)
Co-authored-by: Miguel Perez Pellicer <[email protected]>
as npm fails to resolve shelljs dependency.
from `-tracking-jsdoc`.
It has nothing to do with Tracking, it's just our code convention.
Base automatically changed from add/jsdoc to trunk June 2, 2022 20:08
from the `-jsdoc` readme.
The plugin should be already installed given the budnle is.
@tomalec tomalec requested a review from a team June 3, 2022 10:21
@tomalec tomalec self-assigned this Jun 3, 2022
@tomalec tomalec marked this pull request as ready for review June 3, 2022 18:03
* Internal dependencies
*/
import { shell } from '../utils.js'
process.env.PATH += ( path.delimiter + path.join( process.cwd(), 'node_modules', '.bin') );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is repeated over all the bin files, so I guess could be reuse it in utils.js kinda file.

Copy link
Member Author

@tomalec tomalec Jun 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In all 2 ;) We cannot.
as npm fails to resolve shelljs dependency in a parent folder without its own package.json
9914196

Plus it's single line

/**
 * Internal dependencies
 */
import { shell } from '../../utils.js'

vs.

import shell from 'shelljs';
import path from 'path';

process.env.PATH += ( path.delimiter + path.join( process.cwd(), 'node_modules', '.bin') );

So not a big difference in LOC, and a bit more explicit, that it's just the original shelljs

@puntope
Copy link
Contributor

puntope commented Jun 7, 2022

⚠️

When I ran the installation I got this error:

➜  npm i --save-dev "https://gitpkg.now.sh/woocommerce/grow/packages/js/jsdoc?add/jsdoc-bundle"
npm ERR! code ENOLOCAL
npm ERR! Could not install from "node_modules/tracking-jsdoc" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/miguelperezpellicer/.npm/_logs/2022-06-07T12_58_34_945Z-debug.log

instead of relative FS path, to make the `jsdoc` package installable elsewhere.

Related to #5

Address #10 (comment)
@tomalec
Copy link
Member Author

tomalec commented Jun 7, 2022

When I ran the installation I got this error:

Thanks, it was a leftover from my local testing with a relative filesystem reference. Fixed in 8b88bfd

@tomalec
Copy link
Member Author

tomalec commented Jun 7, 2022

@puntope would you mind another look?

@tomalec tomalec requested a review from puntope June 7, 2022 20:45
Copy link
Contributor

@puntope puntope left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM

I was able to install the plugin and generate the tracking docs

Thanks ❤️

@tomalec tomalec merged commit 69d8a73 into trunk Jun 8, 2022
@tomalec tomalec deleted the add/jsdoc-bundle branch June 8, 2022 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants